home *** CD-ROM | disk | FTP | other *** search
- /*rx
- *
- * GetSizesLhA.rexx - Find total size of all files selected in a DOpus
- * LhA buffer window
- *
- * $VER: GetSizesLhA 40.3 (22/05/94) by Geoff Seeley
- *
- * Usage: ARexx command GetSizesLhA.rexx (from DOpus)
- *
- */
-
- /*---------------------------------------------------------------------------*/
-
- /* misc. variables */
-
- DOpusPort = 'DOPUS.1'
-
- if ~show(l,"rexxsupport.library") then
- call addlib("rexxsupport.library",0,-30,0)
-
- /* make sure we've got somebody to talk to */
-
- if showlist('Ports', DOpusPort) = 0 then do
- say 'Directory Opus ARexx port not found. Aborting.'
- call CleanUp
- end
-
- address 'DOPUS.1'
- options results
-
- /* get the path/name of the LhA archive file */
-
- 'Status 14 -1'
- LhaArchive = result
-
- /* make sure it's an LhA archive listing buffer */
-
- if IsLhaFile(LhaArchive) = 0 then do
-
- /* try the other window */
-
- OtherWindow
- 'Status 14 -1'
- LhaArchive = result
-
- if IsLhaFile(LhaArchive) = 0 then do
-
- Notify "Sorry, No LhA archive buffer found. You must use the ListLha button first."
- call CleanUp
-
- end
-
- end
-
- /* get total count of files */
-
- 'Status 6 -1'
- TotalFiles = result - 1
-
- /* get total bytes in archive */
-
- GetEntry TotalFiles
- TotalBytes = result
-
- TotalBytes = substr(TotalBytes, 1, 9)
- TotalBytes = strip(TotalBytes)
-
- /* adjust total for footer */
-
- TotalFiles = TotalFiles - 2
-
- /* get list of selected entries */
-
- GetSelectedAll
- SelectedEntries = result
-
- if SelectedEntries = 'RESULT' then do
-
- Notify "Please select file(s) to total..."
- call CleanUp
-
- end
-
- NumberOfEntries = words(SelectedEntries)
-
- Busy on
-
- /* sum the files */
-
- NumberOfBytes = 0
- NumberOfFiles = 0
-
- call SumEachFile
-
- TopText "Files: " || NumberOfFiles || "/" || TotalFiles || " Bytes: " || NumberOfBytes || "/" || TotalBytes
-
- Busy off
-
- exit 0
-
- /*----------------------------------------------------------------------------*/
-
- SumEachFile: /* add each selected file to total */
-
- do EntryNumber = 1 to NumberOfEntries
-
- /* get entry number, retrieve entry */
-
- Index = word(SelectedEntries, EntryNumber)
-
- GetEntry Index + 1
- Entry = result
-
- /* grab file name/path */
-
- File = substr(Entry, 10)
- Size = substr(Entry, 1, 9)
-
- NumberOfFiles = NumberOfFiles + 1
- NumberOfBytes = NumberOfBytes + Size
-
- /* make sure user see's the entry */
-
- TopText "Files: " || NumberOfFiles || "/" || TotalFiles || " Bytes: " || NumberOfBytes || "/" || TotalBytes
-
- end
-
- return
-
- /*---------------------------------------------------------------------------*/
-
- IsLhAFile: procedure /* look at extension, return 1 if right, else 0 */
-
- parse arg AFileName
-
- lps = lastpos(".", AFileName)
- if lps = 0 then
- return 0
-
- FileExt = upper(right(AFileName,length(AFileName)-lps))
-
- if FileExt ~= "LHA" & FileExt ~= "LZH" then
- return 0
- else
- return 1
-
- return 0
-
- /*---------------------------------------------------------------------------*/
-
- CleanUp: /* clean up and exit */
-
- Busy off
-
- exit 0
-
- return
-
-